<?php
namespace Home\Model;
use Think\Model;
class IntentionModel extends Model {
	public $table='zjy_member_address';
	public $page; //当前页
	public $perpage; //每页显示
	public $match_id; //ID
	public $pc_id; //分类ID
	public $post; //提交的信息 数组
	public $ids; //IDs 主要用于删除
	public $sorts; //IDs 主要用于删除
	public $keyword; //关键词
	public $pc_ids; //获取分类ID下的子分类
	public $member_id; //

	//获取用户地址列表
	public function get_intention_list(){
		$Model=M("Intention");
		$Purchase=M("Purchase");
		$Supply=M("Supply");
		$Member=M("Member");
		$member_id=intval($this->member_id);
		$intention_type=intval($this->intention_type);
		$list=$Model->where('member_id='.$member_id.' and intention_type='.$intention_type)->select();
		foreach ($list as $k => $v) {
			$purchase_member_id=$Purchase->where('purchase_id='.$v['purchase_id'])->getField('member_id');
			$list[$k]['purchase_name']=$Member->where('member_id='.intval($purchase_member_id))->getField('member_truename');
			$supply_member_id=$Supply->where('supply_id='.$v['supply_id'])->getField('member_id');
			$list[$k]['supply_name']=$Member->where('member_id='.intval($supply_member_id))->getField('member_truename');
		}
		return $list;
	}
	//意向信息添加
	public function intention_add_post(){
		$Model=M("Intention");
		$data=$this->post;
		if($Model->add($data)){
			return true;
		}else{
			return false;
		}
	}
}